//
//  XCMainController.m
//  weibo-OC
//
//  Created by 1 on 16/3/6.
//  Copyright © 2016年 1. All rights reserved.
//

#import "XCMainController.h"
#import "XCHomeController.h"
#import "XCMessageController.h"
#import "XCDiscoverController.h"
#import "XCProfileController.h"
#import "XCTabBar.h"

@interface XCMainController ()

@end

@implementation XCMainController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    XCTabBar *myTabBar = [[XCTabBar alloc]init];
    [self setValue:myTabBar forKey:@"tabBar"];
    

    
    [self addChilds];
}

//添加控制器
- (void) addChilds{
    
    [self addChildController:[[XCHomeController alloc]init] title:@"主页" image:@"tabbar_home" selectImage:@"tabbar_home_selected"];
    
    [self addChildController:[[XCMessageController alloc]init] title:@"消息" image:@"tabbar_message_center" selectImage:@"tabbar_message_center_selected"];
    
    [self addChildController:[[XCDiscoverController alloc]init] title:@"发现" image:@"tabbar_discover" selectImage:@"tabbar_discover_selected"];
    
    [self addChildController:[[XCProfileController alloc]init] title:@"我" image:@"tabbar_profile" selectImage:@"tabbar_profile_selected"];
}


//添加navigationcontroller
- (void) addChildController:(UIViewController *)vc  title:(NSString *)title image:(NSString *)image selectImage:(NSString *)selectImage{
    
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:vc];
    
    [self addChildViewController:navi];
    
    //设置tabBar的属性
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];
    
    //设置颜色
    self.tabBar.tintColor = [UIColor orangeColor];
}

@end
